﻿@model FinancesViewModel
@{
    ViewBag.Title = "RentCash";
    Layout = "~/Views/Shared/CustomerLayout.cshtml";
}

<h2>Finanse</h2>

@if (Model != null && Model.Messages.Count() > 0)
{
    foreach(String message in Model.Messages)
    {
        <div class="ResultOk" style="background-image: none; background-color:#870403; border: solid 1px black; padding: 10px; margin: 10px; float: left; width: 310px;">@message</div>
    }
}

@if (Model != null && Model.Hires.Count<Hires>() > 0)
{
    <table class="list" style="width: 100%;">
        <thead>
            <tr>
                <td>Lokalizacja</td>
                <td>Film</td>
                <td>Nośnik</td>
                <td>Data zwrotu</td>
                <td>Koszt planowany</td>
                <td>Zapłacono</td>
            </tr>
        </thead>
        @foreach (Hires hire in Model.Hires)
        {
            string style = string.Empty;
            
            if (!hire.HireIsDiscReturned)
            {
                style = "background-color: #ff7675; ";
            }
            
                <tr style='@style'>
                    <td>@hire.Discs.Agencies.AgencyName</td>
                    <td>@hire.Discs.Movies.MovieTitle</td>
                    <td>@hire.Discs.DiscTypes.DiscTypeName</td>
                    <td>@hire.HirePlanningReturningDate.Value.ToString("dd.MM.yyyy")</td>
                    <td>@string.Format("{0:0.00}zł", hire.HirePlanningCost)</td>
                    <td>@string.Format("{0}", hire.HireIsDiscReturned ? "Tak":"Nie")</td>
                 </tr>
        }
    </table>
    
    <div class="pagesNavigation">
        @Html.PageLinks(Model.PagingInfo, x => Url.Action("RentCash", new { page = x }))
    </div>
}
else
{
    <p>Nie wypożyczyłeś żadnego filmu</p> 
}